//
//  HotLiveView.m
//  Bread-Live
//
//  Created by ios on 2017/3/14.
//  Copyright © 2017年 Chris. All rights reserved.
//

#import "HotLiveView.h"

@interface HotLiveView ()
@property(nonatomic,strong) UIImageView *bgImageView;
@property(nonatomic,strong) UILabel     *descritionLabel;
@property(nonatomic,strong) UILabel     *liveTypeLabel;
@property(nonatomic,strong) UILabel     *timeLabel;

@end

@implementation HotLiveView


-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self configView];
        
    }
    return self;
}

-(void)configView{
    CGFloat viewW = self.frame.size.width;
    CGFloat viewH = self.frame.size.height;
    
    _bgImageView  = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, viewW, viewH)];
    _bgImageView.contentMode = UIViewContentModeScaleAspectFill;
    _bgImageView.clipsToBounds = YES;
    
    
    [self addSubview:_bgImageView];
    
    _descritionLabel  = [[UILabel alloc] initWithFrame:CGRectMake(25, viewH*0.3, viewW-50, 42)];
    _descritionLabel.contentMode     = UIViewContentModeCenter;
    _descritionLabel.numberOfLines   = 2;
    _descritionLabel.textColor       = [UIColor whiteColor];
    _descritionLabel.backgroundColor = [UIColor clearColor];
    _descritionLabel.textAlignment   = NSTextAlignmentCenter;
    _descritionLabel.font            = [UIFont wyBlodFont:17];
    
    [self addSubview:_descritionLabel];
    
    _liveTypeLabel   = [[UILabel alloc] initWithFrame:CGRectMake(viewW/2-100, viewH *0.3+52, 90, 21)];
    
    _liveTypeLabel.textColor = [UIColor whiteColor];
    _liveTypeLabel.backgroundColor = [UIColor clearColor];
    _liveTypeLabel.textAlignment   = NSTextAlignmentRight;
    _liveTypeLabel.font        = [UIFont wyNormalFot:15];
    
    [self addSubview:_liveTypeLabel];
    
    UIView *whiteLineView = [[UIView alloc] initWithFrame:CGRectMake(viewW/2, viewH*0.3+52, 1.5, 21)];
    whiteLineView.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:whiteLineView];
    
}


-(void)initWithBackgroundImageUrl:(NSString *)bgImageUrl descritionText:(NSString *)descritionText liveType:(NSString *)type liveTime:(NSString *)time{
    CGFloat viewW = self.frame.size.width;
    CGFloat viewH = self.frame.size.height;
    
    CGFloat width = [ToolsCustom setLabelText:time textFont:[UIFont wyNormalFot:13]] +10;
    
    _timeLabel  = [[UILabel alloc] initWithFrame:CGRectMake(viewW/2+3.5, viewH *0.3+52, width, 21)];
    
    _timeLabel.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.6];
    _timeLabel.textColor       = [UIColor blackColor];
    _timeLabel.text            = time;
    _timeLabel.font            = [UIFont wyNormalFot:12];
    _timeLabel.textAlignment   = NSTextAlignmentCenter;
    
    [self addSubview:_timeLabel];
    
    UIView *whiteLineView = [[UIView alloc] initWithFrame:CGRectMake(viewW/2+5.5+width, viewH*0.3+52, 1.5, 21)];
    whiteLineView.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:whiteLineView];
    
    [_bgImageView sd_setImageWithURL:[NSURL URLWithString:bgImageUrl]];
    
    _descritionLabel.text  = descritionText;
    _liveTypeLabel.text = type;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
